//
//  RVideoCacheItemView.m
//  iAccountBook
//
//  Created by 侯伟 on 2021/9/25.
//

#import "RVideoCacheItemView.h"

@implementation RVideoCacheItemView

- (instancetype)init{
    if(self = [super init]){
        
        self.backgroundColor = COLOR_BACKGEOUND;
        self.myHeight = PX(36);
        self.widthSize.equalTo(@(MyLayoutSize.wrap)).min(100).add(16);
        [self setTarget:self action:@selector(selectItem:)];
        
        [self initSubView];
    }
    return self;
}

- (void)initSubView{
    UILabel* nameLb = [UILabel lableWithFont:FONT_FIT(12) color:COLOR_GRAY_BASE text:@""];
    nameLb.adjustsFontSizeToFitWidth = YES;
    nameLb.textAlignment = NSTextAlignmentCenter;
    nameLb.myCenterY = 0;
    nameLb.myHorzMargin = 10;
    [self addSubview:nameLb];
    _nameLb = nameLb;
    
    UIImageView *imageView = [UIImageView new];
    imageView.myBottom = imageView.myRight = 0;
    [self addSubview:imageView];
    _statusIcon = imageView;
}


- (void)setSelected:(BOOL)selected{
    [super setSelected:selected];
    
    if(selected){
        self.nameLb.textColor = COLOR_THEME;
    }else{
        self.nameLb.textColor = COLOR_GRAY_BASE;
    }
}

- (void)selectItem:(id)sender{
    if(self.block){
        self.block(self.tag - 100);
    }
}
@end
